package com.example.microservciefbztestprovider.controller;

import com.example.microservciefbztestprovider.dao.UserMapper;
import com.example.microservciefbztestprovider.domain.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/api/user")
public class UserController {

    static Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    UserMapper userMapper;

    @PostMapping("login")
    public HashMap<String,Object> login(@RequestBody User user){
        logger.info("the loginInfo i get is:{}",user);
        HashMap<String ,Object> map=new HashMap<>();
        Object result=userMapper.findIdAndUsernameByUsernameAndPassword(user);
        map.put("userInfo",result);
        map.put("result","LOGIN_SUCCESS");
        return map;
    }
}
